﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;
using System.Threading;

namespace Wjs.Controllers
{
    public class EchoPostController : Controller
    {
        //
        // GET: /EchoPost/

        [HttpPost]
        public ActionResult Index()
        {
            Thread.Sleep(3000); // Simulate delay

            Stream inputStream = Request.InputStream;
            using (StreamReader reader = new StreamReader(inputStream))
            {
                try
                {
                    inputStream.Position = 0;
                    return Content(Request.RawUrl + " -> " + reader.ReadToEnd());
                }
                catch (Exception exception)
                {
                    return Content(exception.Message);
                }
                finally
                {
                    inputStream.Position = 0;
                }
            }           
        }

    }
}
